package main

import (
	"log"
	"net/http"
	"os"

	"github.com/kubeflow/kronos-server/test/handler"
)

func main() {
	log.SetOutput(os.Stdout)
	apiHandler, err := handler.CreateHTTPAPIHandler()
	if err != nil {
		log.Fatalf("Error while creating the API Handler: %v", err)
	}

	// wsContainer := restful.NewContainer()
	// wsContainer.Router(restful.CurlyRouter{})
	// wsContainer.Add(handler.NewUserService())

	userHandler, err := handler.CreateUserServiceHandler()
	if err != nil {
		log.Fatalf("Error while creating the user service Handler: %v", err)
	}

	http.Handle("/tfjobs/api/", apiHandler)
	http.Handle("/users", userHandler)

	p := ":8080"
	log.Println("Rest api available at /tfjobs/api/ on port", p)

	// log.Fatal(http.ListenAndServe(p, wsContainer))

	if err = http.ListenAndServe(p, nil); err != nil {
		log.Fatalf("Failed to serve: %v", err)
	}
}
